package com.jiguang.Electricvehicle;

import android.widget.Toast;

import com.jiguang.Electricvehicle.app.App;


/**
 * UI通用方法类
 */
public class ToastUtil {

    private static Toast mToast;

    public static final void toastLongMessage(final String message) {
        BackgroundTasks.getInstance().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (mToast != null) {
                    mToast.cancel();
                    mToast = null;
                }
                mToast = WarpToast.createToast(App.getInstance(), message,
                        Toast.LENGTH_LONG);
                mToast.show();
            }
        });
    }

    public static final void toastShortMessage(final String message) {
        try {
            BackgroundTasks.getInstance().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (mToast != null) {
                        mToast.cancel();
                        mToast = null;
                    }
                    mToast =  WarpToast.createToast(App.getInstance(), message,
                            Toast.LENGTH_SHORT);
                    mToast.show();
                }
            });
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
